﻿@model AlbumDetailsViewModel
@{
    ViewBag.Title = "פרויקט - " + Model.Album.Title;
    Random rand = new Random();
}
@section headElements{
    <link href="@Url.Content("~/Content/AlbumDetails.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/AlbumSectionsList.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/AlbumSectionsTable.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/FilmingDaysList.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/AlbumDetails.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/AlbumPrintVersions.js")" type="text/javascript"></script>
}
@Html.Hidden("AlbumId", Model.Album.AlbumId)
@Html.Hidden("HasRender", Model.Album.HasRender.ToString().ToLower())
@Html.HiddenFor(m => m.AlbumSectionsJSON)
@Html.HiddenFor(m => m.FilmingDaysJSON)
<ul id="Breadcrumbs">
    <li><a href="@Url.Action("Index", "Admin")">פאנל ניהול</a></li>
    <li><a href="@Url.Action("Index", "Albums")">פרויקטים</a></li>
    <li>@Model.Album.Title</li>
</ul>
<div id="divAlbumActions" class="highlightedPanel">
    <div class="statusLabel">
        נוצר בתאריך: @Model.Album.CreatedDate | תכולת קבצים: <span id="directorySize">@Model.Album.DirectorySize
            MB</span>
    </div>
    @if (!string.IsNullOrEmpty(Model.Album.CoverThumbnail))
    {
        <img class="CoverThumbnail" src="@Url.Action("Index", "Home")@Model.Album.CoverThumbnail" />
    }
    <div class="albumTitle">
        @Model.Album.Title
    </div>
    <ul class="buttonList">
        <li><a href="@Url.Action("Index", "AlbumImages", new { AlbumId = Model.Album.AlbumId })" class="button">
            <img src="@Url.Content("~/Content/images/buttonIcons/images.png")" />
            תמונות</a></li>
        <li><a href="@Url.Action("Index", "Designer", new { AlbumId = Model.Album.AlbumId })" class="button">
            <img src="@Url.Content("~/Content/images/buttonIcons/design.png")" />
            עצב אלבום</a></li>
        <li><a href="@Url.Action("Index", "Designer", new { AlbumId = Model.Album.AlbumId, designerAction = "Preview" })" class="button">
            <img src="@Url.Content("~/Content/images/buttonIcons/preview.png")" />
            תצוגה מקדימה</a></li>
        <li><a href="" class="button" id="btnSendForApproval">
            <img src="@Url.Content("~/Content/images/buttonIcons/ok.png")" />
            אישור אלבום</a></li>
        <li><a href="" class="button" id="btnSendMailToAlbumEditor">
            <img src="@Url.Content("~/Content/images/buttonIcons/mail.png")" />
            שלח ססמאות </a></li>
        <li><a href="" class="button" id="btnSendMsgMailToAllEditors">
            <img src="@Url.Content("~/Content/images/buttonIcons/mail.png")" />
            שלח הודעה לכל העורכים</a></li>
        <li><a href="" class="button" id="btnViewAlbumFiles">
            <img src="@Url.Content("~/Content/images/buttonIcons/document.png")" />
            קבצי פרויקט</a></li>
        <!--li><a href="" class="button" id="btnDeleteAlbumFiles">
            <img src="@Url.Content("~/Content/images/buttonIcons/delete.png")" />
            רוקן קבצים</a></li-->
    </ul>
    <div class="clear">
    </div>
</div>
<div class="clear topSpace">
</div>
<div id="divAlbumDetails" class="floatRight highlightedPanel">
    <div class="title">
        פרטי אלבום</div>
    <div class="fieldRow">
        <div class="label">
            שם האלבום</div>
        <div class="value">
            @Html.TextBox("Title", Model.Album.Title, new { maxlength = "60" })</div>
    </div>
    <div class="topSpace">
    </div>
    <div class="fieldRow">
        <div class="label">
            מספר עמודים</div>
        <div class="value">
            <span id="NumOfPagesId">
                @Html.TextBox("NumOfPages", Model.Album.NumOfPages, new { maxlength = "60" })
            </span>
        </div>
    </div>
    <div class="fieldRow">
        <div class="label">
            מספר עותקים</div>
        <div class="value">
            @Html.TextBox("NumOfCopies", Model.Album.NumOfCopies, new { @class = "narrowTextbox", type = "number", min = "0" })
        </div>
    </div>
    <div class="fieldRow">
        <div class="label">
            מספר הזמנה
        </div>
        <div class="value">
            @Html.TextBox("OrderNum", Model.Album.OrderNum)
        </div>
    </div>
    <div class="fieldRow">
        <div class="label">
            סוג אלבום</div>
        <div class="value">
            @Model.Album.AlbumSize
        </div>
    </div>
    <div class="fieldRow">
        <div class="label">
            סוג נייר</div>
        <div class="value">
            @Html.Hidden("PaperIdValue", Model.Album.PaperId)
            @Html.DropDownList("PaperId", Model.PapersList)
            <span id="spineWidthMm" class="specText"></span>
        </div>
    </div>
    <div class="fieldRow">
        <div class="label">
            תאריך לסיום
        </div>
        <div class="value">
            @Html.TextBox("DueDate", Model.Album.DueDate, new { @class = "dateTextbox" })
        </div>
    </div>
    <div class="fieldRow">
        <div class="label">
            חד צדדי</div>
        <div class="value">
            @Html.CheckBox("IsOneSided", Model.Album.IsOneSided)
            <label for="IsOneSided">
                אלבום חד צדדי</label></div>
    </div>
    <div class="fieldRow">
        <div class="label">
            צלם</div>
        <div class="value">
            @Html.CheckBox("HasPhotographer", Model.Album.HasPhotographer)
            <label for="HasPhotographer">
                כולל צלם</label></div>
    </div>
    <div class="fieldRow">
        <div class="label">
            גרפיקה</div>
        <div class="value">
            @Html.CheckBox("IncludeGraphics", Model.Album.IncludeGraphics)
            <label for="IncludeGraphics">
                כולל גרפיקה</label></div>
    </div>
    <div class="fieldRow">
        <div class="label">
            עמודים שמורים בתחילת כיתה
        </div>
        <div class="value">
            @Html.TextBox("IntroPagesNumber", Model.Album.IntroPagesNumber, new { @class = "narrowTextbox", type = "number", min = "0" })
        </div>
    </div>
    <div class="fieldRow">
        <div class="label">
            איש מכירות
        </div>
        <div class="value">
            @Html.DropDownList("SalesManId", Model.SalesMenList, "--אין--")
        </div>
    </div>
    <div class="fieldRow">
        <div class="label">
            סטטוס</div>
        <div class="value">
            @Html.Hidden("AlbumStatusIdValue", Model.Album.AlbumStatusId)
            @Html.DropDownList("AlbumStatusId", Model.AlbumStatusesList)</div>
    </div>
    <div class="fieldRow">
        <div class="label">
            מצב נעילה</div>
        <div class="value">
            @Html.Hidden("AlbumLockStatusIdValue", Model.Album.AlbumLockStatusId)
            @Html.DropDownList("AlbumLockStatusId", Model.AlbumLockStatusesList)</div>
    </div>
    <div class="clear">
        <input type="button" value="עדכן" id="btnUpdateAlbumDetails" class="button" />
    </div>
</div>
<div id="divEditorDetails" class="floatRight rightSpace highlightedPanel">
    @using (Html.BeginForm())
    {
        <div class="title">
            פרטי עורך אלבום</div>
        <div class="fieldRow">
            <div class="label">
                סיסמת עורך
            </div>
            <div class="value">
                @Html.TextBoxFor(m => m.Album.EditorPassword)
            </div>
        </div>
        <div class="fieldRow">
            <div class="label">
                אימייל עורך
            </div>
            <div class="value">
                @Html.TextBoxFor(m => m.Album.EditorEmail)
                @Html.ValidationMessageFor(m => m.Album.EditorEmail)
            </div>
        </div>
        <div class="fieldRow">
            <div class="label">
                שם עורך</div>
            <div class="value">
                @Html.TextBoxFor(m => m.Album.EditorFirstName, new { @class = "nameTextbox" })
                @Html.TextBoxFor(m => m.Album.EditorLastName, new { @class = "nameTextbox" })</div>
        </div>
        <div class="fieldRow">
            <div class="label">
                טלפון</div>
            <div class="value">
                @Html.TextBoxFor(m => m.Album.EditorPhone)</div>
        </div>
        <div class="fieldRow">
            <div class="label">
                טלפון נייד
            </div>
            <div class="value">
                @Html.TextBoxFor(m => m.Album.EditorMobile)
            </div>
        </div>
        <div class="clear">
            <input type="button" value="עדכן" id="btnUpdateEditorDetails" class="button" />
        </div>
    }
</div>
<div class="clear">
</div>
<div class="topSpace highlightedPanel">
    <div class="title">
        מקטעים
    </div>
    <table id="SectionsTable" class="width100">
        <tr>
            <th>
                כותרת
            </th>
            <th>
                סוג
            </th>
            <th>
                מס' עמודים
            </th>
            <th>
                סטטוס
            </th>
            <th>
                מצב נעילה
                @Html.DropDownList("SectionLockStatusForAll", Model.AlbumSectionLockStatusesList, "--עדכן הכל--")
            </th>
            <th>
                פרטי עורך
            </th>
            <th>
                הסר
            </th>
        </tr>
    </table>
    <div class="clear topSpace">
        <input type="button" id="btnAddSection" value="הוסף מקטע" class="button" />
    </div>
    <div class="clear topSpace">
        <input type="button" id="btnUpdateAlbumSections" value="עדכן" class="button" />
        <div id="pagesCountNotEqual" class="errorMessage hidden">
            מספר העמודים באלבום לא תואם לסך העמודים במקטעים.</div>
    </div>
</div>
<div class="clear topSpace">
</div>
<div class="highlightedPanel">
    <div class="title">
        ימי צילום
    </div>
    <table id="FilmingDays" class="hidden">
        <tr>
            <th>
                תאריך
            </th>
            <th>
                צלם
            </th>
            <th>
                הסר
            </th>
        </tr>
    </table>
    <div class="clear topSpace">
        <input type="button" id="btnAddFilmingDay" value="הוסף יום צילום" class="button" />
    </div>
    <div id="updateFilmingDaysContainer" class="clear topSpace hidden">
        <input type="button" value="עדכן" id="btnUpdateFilmingDays" class="button" />
    </div>
</div>
<div class="clear topSpace">
</div>
<div class="highlightedPanel">
    <input type="hidden" id="CurrentDate" value="@DateTime.Now.ToShortDateString()" />
    <div id="renderIndicators">
        <div id="IsRenderRun" class="renderIndicator">
        </div>
        <div id="IsRenderProccessEmpty" class="renderIndicator">
        </div>
    </div>
    <div class="title">
        גרסאות דפוס
    </div>
    <div id="albumRenderStatus" class="clear hidden">
    </div>
    <div class="clear">
        <input type="button" class="button" id="btnRenderPages" value="הפק גרסת הדפסה" />
        <input type="button" class="button" id="btnShowRenderDlg" value="הצג דיאלוג רנדור" />
        <div id="allPagesRendered" class="hidden specText">* גרסת דפוס עדכנית</div>
    </div>
    <div class="clear">
    </div>
    <table id="PrintVersions" class="hidden topSpace">
        <tr>
            <th>
                מס'
            </th>
            <th>
                תאריך יצירה
            </th>
            <th>
                סטטוס
            </th>
            <th class="CheckboxDateCol">
                נשלח PDF?
            </th>
            <th class="CheckboxDateCol">
                נשלחה דוגמת דפוס?
            </th>
            <th class="hidden">
                הצג לעורך האלבום
            </th>
            <th class="PdfFilesCol">
                קבצי PDF
            </th>
            <th>
                גודל
            </th>
            <th>
                אישור גרסה
            </th>
            <th>
                הסר
            </th>
        </tr>
    </table>
    <div id="updatePrintVersionsContainer" class="clear topSpace hidden">
        <input type="button" value="עדכן" id="btnUpdatePrintVersions" class="button" />
    </div>
</div>
@if (UserHelper.HasPermission((int)AlbumDesigner.Models.Enums.AlbumUsers.Admin))
{
    <div class="clear topSpace highlightedPanel">
        <div class="title">
            סטודיו
        </div>
        <div class="fieldRow">
            <div class="label">
                הערות סטודיו
            </div>
            <div class="value">
                @Html.TextArea("StudioNotes", Model.Album.StudioNotes, new { rows = "5", cols = "50" })
            </div>
        </div>
        <div class="clear">
            <input type="button" value="עדכן" id="btnUpdateStudioNotes" class="button" />
        </div>
    </div>
}
<div class="clear topSpace">
</div>
<div id="divAlbumPasswords" class="floatRight highlightedPanel">
    <div class="title">
        קובץ סיסמאות
    </div>
    <a class="button" href="@Url.Action("EditorsFile", new { id = Model.Album.AlbumId })">
        הורד קובץ סיסמאות </a>
</div>
<div id="divAlbumContract" class="floatRight rightSpace highlightedPanel">
    <div class="title">
        חוזה
    </div>
    <div id="divContractFile">
        <a href="" class="button" target="_blank">צפה</a>
    </div>
    <div id="divUploadContract">
        @using (Html.BeginForm("UploadContractPDF", "Albums", FormMethod.Post, new { enctype = "multipart/form-data" }))
        {
            @Html.Hidden("id", Model.Album.AlbumId)
            <a href="" class="button">הוסף</a>
            <input type="file" id="ContractPdfFile" name="ContractPdfFile" />
        }
    </div>
    <div class="clear">
    </div>
</div>
<script id="sectionRowTemplate" type="text/x-jquery-tmpl">
    <tr>
        <td>
            <input type="text" name="SectionTitle" />
            <input type="hidden" name="AlbumSectionId" />
        </td>
        <td>
            {{if AlbumSectionTypeId == 1}}
                כריכה <input type="hidden" name="AlbumSectionTypeId" value="${AlbumSectionTypeId}" />
            {{else}}
                @Html.DropDownList("AlbumSectionTypeId", Model.AlbumSectionTypesList)
            {{/if}}
        </td>
        <td>
            {{if AlbumSectionTypeId == 1}}
                - <input type="hidden" name="PagesCount" value="${PagesCount}" />
            {{else}}
                <input type="number" name="PagesCount" min="2" max="100" step="2" value="${PagesCount}" />
            {{/if}}
            <span class="pagesDecreaseWarning errorText" style="visibility:hidden;">*</span>
        </td>
        <td>
            @Html.DropDownList("AlbumSectionStatusId", Model.AlbumSectionStatusesList)
        </td>
        <td>
            @Html.DropDownList("AlbumSectionLockStatusId", Model.AlbumSectionLockStatusesList)
        </td>
        <td>
            <a href="" class="showSectionEditorForm">פרטי עורך +</a>
        </td>
        <td>
            <a href="" class="removeSection">הסר</a>
        </td>
    </tr>
    <tr class="hidden editorFormRow">
        <td colspan="8">
            <div class="fieldRow">
                <div class="label">
                   סיסמת עורך</div>
                <div class="value">
                    <input type="text" name="EditorPassword" value="${EditorPassword}" /></div>
            </div>
            <div class="fieldRow">
                <div class="label">
                   אימייל עורך</div>
                <div class="value">
                    <input type="text" name="EditorEmail" /></div>
            </div>
            <div class="fieldRow">
                <div class="label">
                   שם עורך</div>
                <div class="value">
                    <input type="text" name="EditorFirstName" class="nameTextbox" />
                    <input type="text" name="EditorLastName" class="nameTextbox" />
                </div>
            </div>
            <div class="fieldRow">
                <div class="label">
                   טלפון עורך</div>
                <div class="value">
                    <input type="text" name="EditorPhone" /></div>
            </div>
            <div class="fieldRow">
                <div class="label">
                   טלפון נייד עורך</div>
                <div class="value">
                    <input type="text" name="EditorMobile" /></div>
            </div>
        </td>
    </tr>
</script>
<script id="filmingDayRowTemplate" type="text/x-jquery-tmpl">
    <tr>
        <td>
            <input type="text" name="Date" class="dateTextbox" value="${DateVal}" />
        </td>
        <td data-photographer-id="${PhotographerId}">
            @Html.DropDownList("PhotographerId", Model.PhotographersList, "--בחר--")
        </td>
        <td>
            <a href="" class="removeFilmingDay">הסר</a>
        </td>
    </tr>
</script>
<script id="printVersionRowTemplate" type="text/x-jquery-tmpl">
    <tr>
        <td>
            ${VersionIdx}
            <input type="hidden" name="AlbumPrintVersionId" value="${AlbumPrintVersionId}" />
        </td>
        <td>
            ${VersionDate}
        </td>
        <td>
            @Html.DropDownList("AlbumPrintVersionStatusId", Model.AlbumPrintVersionStatusesList)
        </td>
        <td>
            <input type="checkbox" class="IsSent IsPdfSent" />
            <input type="text" name="PdfSentDate" value="${PdfSentDate}" class="hidden dateTextbox" />
        </td>
        <td>
            <input type="checkbox" class="IsSent IsPrintSent" />
            <input type="text" name="PrintSentDate" value="${PrintSentDate}" class="hidden dateTextbox" />
        </td>
        <td class="hidden">
            <input type="checkbox" class="ShowToAlbumEditor" id="ShowToAlbumEditor_${AlbumPrintVersionId}" />
            <label for="ShowToAlbumEditor_${AlbumPrintVersionId}">הצג</label>
            <input type="hidden" name="ShowToAlbumEditor" value="${ShowToAlbumEditor}" />
        </td>
        <td>
            {{if InnerPdfFilePath != ""}}
                <a href="@Url.Content("~/")${InnerPdfFilePath}" target="_blank" title="${InnerPdfSize} MB">PDF אלבום</a>
                |
                <a href="@Url.Content("~/")${CoverPdfFilePath}" target="_blank" title="${CoverPdfSize} MB">PDF כריכה</a>
            {{else}}
                -
            {{/if}}
            <div class="hidden">
                {{if InnerPdfFilePath != ""}}
                    <a href="" class="lnkDeletePDFfiles" data-inner-file="${InnerPdfFilePath}" data-cover-file="${CoverPdfFilePath}">מחק קבצים</a>
                {{else}}
                    -
                {{/if}}
            </div>
        </td>
        <td class="filesSize">
            ${PdfFilesSize} MB
        </td>
        <td>
            <a href="" class="showApprovalFileDialog">קובץ אישור</a>
        </td>
        <td>
            <a href="" class="removePrintVersion">&nbsp;&nbsp;הסר</a>
        </td>
    </tr>
</script>
